package com.sirun.cn.fca.module.main.home.temp.control;

import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.TextView;

import com.jungly.gridpasswordview.GridPasswordView;
import com.sirun.cn.fca.R;
import com.sirun.cn.fca.module.main.home.temp.control.constant.ControlIntentConst;
import com.sirun.cn.fca.module.main.home.temp.control.constant.PathConst;
import com.tencent.cloud.iov.router.Router;
import com.tencent.cloud.uikit.ui.BaseIovActivity;

public class PinActivity extends BaseIovActivity {
    private TextView mNextTV, mForgetTV;
    private GridPasswordView mPinGPV;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setFinishOnTouchOutside(true);
        setContentView(R.layout.pin_activity);

        getWindow().setBackgroundDrawable(new ColorDrawable(0));//去除边框

        mPinGPV = this.findViewById(R.id.gpv_pin);
        mNextTV = this.findViewById(R.id.tv_pin_next);
        mPinGPV.togglePasswordVisibility();
        final int type = getIntent().getIntExtra(ControlIntentConst.FROM, 0);
        String pin = mPinGPV.getPassWord();
//        if (!TextUtils.isEmpty(pin)) {
        mNextTV.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                controlIntent(type);
            }
        });
//        } else {
//            Toast.makeText(this, "请输入PIN码", Toast.LENGTH_SHORT).show();
//        }
    }

    private void controlIntent(int type) {
        String path = PathConst.CONTROL;
        Intent controlIntent = Router.fromPath(path);
        controlIntent.putExtra(ControlIntentConst.FROM, type);
        startActivity(controlIntent);
        finish();
    }
}
